home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / datatypes / dfadt / source / dfadt_class.c < prev    next >
C/C++ Source or Header  |  1996-04-07  |  18KB  |  760 lines

  1. /* $Revision Header built automatically *************** (do not edit) ************
  2. **
  3. ** © Copyright by Dirk Federlein
  4. **
  5. ** File             : Work:programming/dfa/Sourcen_V2.3/Datatypes/dfadt_class.c
  6. ** Created on       : Dienstag, 14.03.95 15:08:28
  7. ** Created by       : Dirk Federlein
  8. ** Current revision : V1.0
  9. **
  10. **
  11. ** Purpose
  12. ** -------
  13. **     DFA datatpye dispatcher and support functions
  14. **
  15. ** Revision V1.0
  16. ** --------------
  17. ** created on Dienstag, 14.03.95 15:08:28  by  Dirk Federlein.   LogMessage :
  18. **     --- Initial release ---
  19. **
  20. *********************************************************************************/
  21.  
  22. #include "all_includes.h"
  23. #include "dfadt.h"
  24.  
  25. long __saveds dfadt_setentry(struct DDTData * dd, struct Address * adr, long id, void * contents);
  26. struct Address * __saveds dfadt_addnode( struct DDTData * dd);
  27. struct FIELDDESC * dfadt_readprefs(struct DDTData * dd);
  28.  
  29.     // Default format
  30.  
  31. static struct FIELDDESC FIELDS[] =
  32. {
  33.     {0,        "Salutation: ",    10}, // 0:  SALUTATION
  34.     {1,        " First: ",        20}, // 1:  First name
  35.     {2,        " Name: ",        20}, // 2:  Name
  36.     {3,        " c/o: ",        20}, // 3:  c/o
  37.     {4,        " Street: ",    20}, // 4:  Street
  38.     {5,        " ZIP: ",        10}, // 5:  ZIP/PC
  39.     {6,        " City: ",        15}, // 6:  City
  40.     {7,        " State: ",        15}, // 7:  State
  41.     {8,        " Country: ",    20}, // 8:  Country
  42.     {9,        " Birthday: ",    10}, // 9: Birthday
  43.     {10,    " Phone: ",        20}, // 10: Phone,
  44.     {11,    " Fax: ",        20}, // 11: Fax,
  45.     {12,    " EMail1: ",    20}, // 12: EMail1,
  46.     {13,    " EMail2: ",    20}, // 13: EMail2,
  47.     {14,    " EMail3: ",    20}, // 14: EMail3,
  48.     {15,    " Comment: ",    20}, // 15: Comment,
  49.     {-1,    NULL,            0}     // End of Array
  50. };
  51.  
  52.     /*
  53.      *    Perform notification
  54.      */
  55.  
  56.  
  57. ULONG __inline dfadt_notify(Object * o, void * ginfo, ULONG flags, ULONG tag1,...)
  58. {
  59.     return(DoMethod(o, OM_NOTIFY, &tag1, ginfo, flags));
  60. }
  61.  
  62. BOOL __inline dfadt_fieldused(struct FIELDDESC * fdesc, LONG id)
  63. {
  64.     long    i    = 0;
  65.  
  66.     while (fdesc[i].offset != -1L)
  67.     {
  68.         if (fdesc[i].offset == id)
  69.             return(TRUE);
  70.  
  71.         i++;
  72.     }
  73.  
  74.     return (FALSE);
  75. }
  76.  
  77.  
  78.     /*
  79.      *    Do the layout
  80.      */
  81.  
  82. ULONG __saveds dfadt_layout(Class * cl, Object * obj, struct gpLayout * gpl)
  83. {
  84.     char                    * buffer;
  85.     char                    * title;
  86.  
  87.     struct DTSpecialInfo    * si        = (struct DTSpecialInfo *) G(obj)->SpecialInfo;
  88.     struct DDTData            * dd        = INST_DATA(cl,obj);
  89.     struct DrawInfo            * dri        = (gpl->gpl_GInfo) ? gpl->gpl_GInfo->gi_DrInfo : NULL;
  90.  
  91.     struct FIELDDESC        * fdesc     = NULL;
  92.     struct IBox                * domain;
  93.     struct List                * linelist;
  94.     struct RastPort            trp;
  95.     struct TextAttr            * tattr;
  96.     struct TextFont            * font;
  97.  
  98.     ULONG                    bsig        = 0;
  99.     ULONG                    bufferlen;
  100.     ULONG                    hunit;
  101.     ULONG                    total    =     0;
  102.     ULONG                    visible;
  103.     ULONG                    wrap;
  104.  
  105.         // Get needed attributes...
  106.  
  107.     if(GetDTAttrs(obj,
  108.         DTA_TextFont,    (ULONG) &font,
  109.         DTA_TextAttr,    (ULONG) &tattr,
  110.         DTA_Domain,        (ULONG) &domain,
  111.         DTA_ObjName,    (ULONG) &title,
  112.         TDTA_LineList,    (ULONG) &linelist,
  113.         TDTA_Buffer,    (ULONG) &buffer,
  114.         TDTA_BufferLen,    (ULONG) &bufferlen,
  115.         TDTA_WordWrap,    (ULONG) &wrap,
  116.         TAG_DONE) == 8)
  117.     {
  118.         struct Line    * line;
  119.         ULONG        maxwidth    = 0;
  120.         ULONG        xoffset        = 0;
  121.         ULONG        nextxoffset    = 0;
  122.         ULONG        yoffset        = 0;
  123.         UBYTE        fgpen        = (dri)?dri->dri_Pens[TEXTPEN]:1;
  124.         UBYTE        bgpen        = (dri)?dri->dri_Pens[BACKGROUNDPEN]:0;
  125.  
  126.             // Lock global data...
  127.  
  128.         ObtainSemaphore (&(si->si_Lock));
  129.  
  130.             // The (text) buffer is absolutely needed:-)
  131.  
  132.         if(buffer)
  133.         {
  134.                 // Init temp rport...
  135.  
  136.             InitRastPort (&trp);
  137.  
  138.  
  139.                 // Set font for this rport...
  140.  
  141.             SetFont (&trp, font);
  142.  
  143.                 // Text layout is done only once...
  144.  
  145.             if (gpl->gpl_Initial)
  146.             {
  147.                 char    * linebuffer;
  148.  
  149.                     // Init lists...
  150.  
  151.                 NewList(linelist);
  152.                 NewList(&(dd->ddt_List));
  153.  
  154.                     // Delete pool if there is one...
  155.  
  156.                 if(dd->ddt_Pool)
  157.                 {
  158.                     DeletePool(dd->ddt_Pool);
  159.                     dd->ddt_Pool = NULL;
  160.                 }
  161.  
  162.                     // Create new one...
  163.  
  164.                 if((dd->ddt_Pool = CreatePool(MEMF_CLEAR | MEMF_ANY , PUDDLE_SIZE, TRESH_SIZE)))
  165.                 {
  166.                         // Read preferences file (ENV:DFADT.prefs)
  167.  
  168.                     if ((fdesc = dfadt_readprefs(dd)) == NULL)
  169.                         fdesc = FIELDS;
  170.  
  171.                         // Get linebuffer...
  172.  
  173.                     if((linebuffer = AllocPooled(dd->ddt_Pool,BUFFER_SIZE)))
  174.                     {
  175.                         ULONG                swidth;
  176.                         ULONG                style            = FS_NORMAL;
  177.  
  178.  
  179.                         LONG                err            = 0L;
  180.                         ULONG                icnt        = 0;
  181.                         ULONG                j,k            = 0;
  182.                         ULONG                adrlines    = 0;
  183.                         ULONG                version        = 0;
  184.  
  185.  
  186.                         ULONG                lcnt        = 0;
  187.                         ULONG                bufferpos    = 0;
  188.                         ULONG                endpos        = 0;
  189.                         ULONG                linepos        = 0;
  190.  
  191.                         struct Address        * adr        = NULL;
  192.  
  193.                             // "Init" linebuffer...
  194.  
  195.                         *linebuffer = EOS;
  196.  
  197.                             // Compute the "magic"
  198.  
  199.                         stccpy(linebuffer, buffer, DFAMAGICLEN+1);
  200.  
  201.                         if (strcmp(linebuffer, DFA11MAGIC))
  202.                         {
  203.                             if (strcmp(linebuffer, DFAMAGIC))
  204.                             {
  205.                                 if (strcmp(linebuffer, DFA13MAGIC))
  206.                                 {
  207.                                     if (strcmp(linebuffer, DFA14MAGIC))
  208.                                     {
  209.                                         if (strcmp(linebuffer, DFA15MAGIC))
  210.                                         {
  211.                                             err    = 10L;
  212.                                             goto end;
  213.                                         }
  214.                                         else
  215.                                         {
  216.                                             version        = 15;
  217.                                             adrlines    = DFA15LINES;
  218.                                         }
  219.                                     }
  220.                                     else
  221.                                     {
  222.                                         version        = 14;
  223.                                         adrlines    = DFA14LINES;
  224.                                     }
  225.                                 }
  226.                                 else
  227.                                 {
  228.                                     version        = 13;
  229.                                     adrlines    = DFA13LINES;
  230.                                 }
  231.                             }
  232.                             else
  233.                             {
  234.                                 version        = 10;
  235.                                 adrlines    = DFALINES;
  236.                             }
  237.                         }
  238.                         else
  239.                         {
  240.                             version    = 11;
  241.                             adrlines    = DFA11LINES;
  242.                         }
  243.  
  244.  
  245.                         bufferpos    = DFAMAGICLEN+1;
  246.                         endpos        = strlen(buffer);
  247.  
  248.                         while ((bufferpos < endpos) && (bsig == 0))
  249.                         {
  250.  
  251.                             if (buffer[bufferpos] == '\n')
  252.                             {
  253.                                 // Line counters
  254.  
  255.                                 lcnt++;        // global
  256.                                 icnt++;        // within address item
  257.  
  258.                                 // Terminate line
  259.  
  260.                                 linebuffer[linepos]        = '\0';
  261.  
  262.                                 switch (icnt)
  263.                                 {
  264.                                     // No zero line :-)
  265.  
  266.                                     case 1:
  267.  
  268.                                         if (adr = dfadt_addnode(dd))
  269.                                         {
  270.                                             if (dfadt_fieldused(fdesc,ITEMOFFSET_NAME))
  271.                                                 if (err = dfadt_setentry (dd, adr, ITEMOFFSET_NAME, linebuffer ))
  272.                                                     goto end;
  273.                                         }
  274.  
  275.                                         break;
  276.  
  277.                                     case 2:
  278.                                         if (dfadt_fieldused(fdesc, ITEMOFFSET_FIRSTNAME))
  279.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_FIRSTNAME, linebuffer ))
  280.                                                 goto end;
  281.  
  282.                                         break;
  283.  
  284.                                     case 3:
  285.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_STREET))
  286.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_STREET, linebuffer ))
  287.                                                 goto end;
  288.  
  289.                                         break;
  290.  
  291.                                     case 4:
  292.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_ZIP))
  293.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_ZIP, linebuffer ))
  294.                                                 goto end;
  295.                                         break;
  296.  
  297.                                     case 5:
  298.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_CITY))
  299.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_CITY, linebuffer ))
  300.                                                 goto end;
  301.  
  302.                                         break;
  303.  
  304.                                     case 6:
  305.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_COUNTRY))
  306.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_COUNTRY, linebuffer ))
  307.                                                 goto end;
  308.                                         break;
  309.  
  310.                                     case 7:
  311.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_BIRTHDAY))
  312.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_BIRTHDAY, linebuffer ))
  313.                                                 goto end;
  314.  
  315.                                         break;
  316.  
  317.                                     case 8:
  318.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_PHONE))
  319.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_PHONE, linebuffer ))
  320.                                                 goto end;
  321.  
  322.                                         break;
  323.  
  324.                                     case 9:
  325.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_EMAIL1))
  326.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_EMAIL1, linebuffer ))
  327.                                                 goto end;
  328.  
  329.                                         break;
  330.  
  331.                                     case 10:
  332.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_EMAIL2))
  333.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_EMAIL2, linebuffer ))
  334.                                                 goto end;
  335.  
  336.                                         break;
  337.  
  338.                                     case 11:
  339.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_EMAIL3))
  340.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_EMAIL3, linebuffer ))
  341.                                                 goto end;
  342.  
  343.                                         break;
  344.  
  345.                                     case 12:
  346.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_COMMENT))
  347.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_COMMENT, linebuffer ))
  348.                                                 goto end;
  349.  
  350.                                         break;
  351.  
  352.                                     case 13:
  353.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_SELECTED))
  354.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_SELECTED, (void *) atoi(linebuffer) ))
  355.                                                 goto end;
  356.  
  357.                                         break;
  358.  
  359.                                     case 14:
  360.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_SALUTATION))
  361.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_SALUTATION, linebuffer ))
  362.                                                 goto end;
  363.  
  364.                                         break;
  365.  
  366.                                     case 15:
  367.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_FAX))
  368.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_FAX, linebuffer ))
  369.                                                 goto end;
  370.                                         break;
  371.  
  372.                                     case 16:
  373.                                         for (k=0; k<8; k++)
  374.                                             adr->as_Data.ad_Groups[k] = linebuffer[k] - '0';
  375.  
  376.                                         break;
  377.  
  378.                                     case 17:
  379.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_CO))
  380.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_CO, linebuffer ))
  381.                                                 goto end;
  382.  
  383.                                         break;
  384.  
  385.                                     case 18:
  386.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_STATE))
  387.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_STATE, linebuffer ))
  388.                                                 goto end;
  389.  
  390.                                         break;
  391.  
  392.                                     case 19:
  393.                                         if(dfadt_fieldused(fdesc, ITEMOFFSET_EXTERNAL))
  394.                                             if (err = dfadt_setentry (dd, adr, ITEMOFFSET_EXTERNAL, linebuffer ))
  395.                                                 goto end;
  396.  
  397.                                         break;
  398.  
  399.                                 }
  400.  
  401.                                     // Last item line ?
  402.  
  403.                                 if ( ! (lcnt % adrlines ))
  404.                                 {
  405.                                     if ((version >= 11) && (lcnt == adrlines))
  406.                                     {
  407.                                         // Throw away the template
  408.  
  409.                                         ; /* DO NOTHING */
  410.                                     }
  411.                                     else
  412.                                     {
  413.                                         // Do the layout
  414.  
  415.                                         j            = 0;
  416.                                         xoffset        = 0;
  417.                                         nextxoffset    = 0;
  418.  
  419.                                         while (fdesc[j].offset != -1L)
  420.                                         {
  421.                                             // Field desc.
  422.  
  423.                                             if (line = AllocPooled(dd->ddt_Pool,sizeof(struct Line)))
  424.                                             {
  425.                                                 line->ln_Text = fdesc[j].description;
  426.  
  427.                                                 line->ln_TextLen    = (line->ln_Text&&line->ln_Text[0])?strlen(line->ln_Text):0;
  428.  
  429.                                                 swidth                = TextLength (&trp, line->ln_Text, line->ln_TextLen);
  430.                                                 xoffset                += nextxoffset;
  431.                                                 nextxoffset            = swidth;
  432.                                                 style                = FS_NORMAL;
  433.  
  434.                                                 line->ln_FgPen   = fgpen;
  435.                                                 line->ln_BgPen   = bgpen;
  436.                                                 line->ln_Style   = style;
  437.                                                 line->ln_Data    = NULL;
  438.                                                 line->ln_XOffset = xoffset;
  439.                                                 line->ln_YOffset = yoffset + font->tf_Baseline;
  440.                                                 line->ln_Width   = swidth;
  441.                                                 line->ln_Height  = font->tf_YSize;
  442.  
  443.                                                 AddTail(linelist, (struct Node *) line);
  444.  
  445.                                             }
  446.  
  447.                                             if (line = AllocPooled(dd->ddt_Pool,sizeof(struct Line)))
  448.                                             {
  449.                                                 switch(fdesc[j].offset)
  450.                                                 {
  451.                                                     case 0:
  452.                                                         line->ln_Text        = adr->as_Data.ad_Salutation?adr->as_Data.ad_Salutation:(UBYTE*)"";
  453.                                                         break;
  454.                                                     case 1:
  455.                                                         line->ln_Text        = adr->as_Data.ad_FirstName?adr->as_Data.ad_FirstName:(UBYTE*)"";
  456.                                                         break;
  457.                                                     case 2:
  458.                                                         line->ln_Text        = adr->as_Data.ad_Name?adr->as_Data.ad_Name:(UBYTE*)"";
  459.                                                         break;
  460.                                                     case 3:
  461.                                                         line->ln_Text        = adr->as_Data.ad_CO?adr->as_Data.ad_CO:(UBYTE*)"";
  462.                                                         break;
  463.                                                     case 4:
  464.                                                         line->ln_Text        = adr->as_Data.ad_Street?adr->as_Data.ad_Street:(UBYTE*)"";
  465.                                                         break;
  466.                                                     case 5:
  467.                                                         line->ln_Text        = adr->as_Data.ad_ZIP?adr->as_Data.ad_ZIP:(UBYTE*)"";
  468.                                                         break;
  469.                                                     case 6:
  470.                                                         line->ln_Text        = adr->as_Data.ad_City?adr->as_Data.ad_City:(UBYTE*)"";
  471.                                                         break;
  472.                                                     case 7:
  473.                                                         line->ln_Text        = adr->as_Data.ad_State?adr->as_Data.ad_State:(UBYTE*)"";
  474.                                                         break;
  475.                                                     case 8:
  476.                                                         line->ln_Text        = adr->as_Data.ad_Country?adr->as_Data.ad_Country:(UBYTE*)"";
  477.                                                         break;
  478.                                                     case 9:
  479.                                                         line->ln_Text        = adr->as_Data.ad_Birthday?adr->as_Data.ad_Birthday:(UBYTE*)"";
  480.                                                         break;
  481.                                                     case 10:
  482.                                                         line->ln_Text        = adr->as_Data.ad_Phone?adr->as_Data.ad_Phone:(UBYTE*)"";
  483.                                                         break;
  484.                                                     case 11:
  485.                                                         line->ln_Text        = adr->as_Data.ad_Fax?adr->as_Data.ad_Fax:(UBYTE*)"";
  486.                                                         break;
  487.                                                     case 12:
  488.                                                         line->ln_Text        = adr->as_Data.ad_EMail1?adr->as_Data.ad_EMail1:(UBYTE*)"";
  489.                                                         break;
  490.                                                     case 13:
  491.                                                         line->ln_Text        = adr->as_Data.ad_EMail2?adr->as_Data.ad_EMail2:(UBYTE*)"";
  492.                                                         break;
  493.                                                     case 14:
  494.                                                         line->ln_Text        = adr->as_Data.ad_EMail3?adr->as_Data.ad_EMail3:(UBYTE*)"";
  495.                                                         break;
  496.                                                     default:
  497.                                                     case 15:
  498.                                                         line->ln_Text        = adr->as_Data.ad_Comment?adr->as_Data.ad_Comment:(UBYTE*)"";
  499.                                                         break;
  500.                                                 }
  501.                                             }
  502.  
  503.                                             line->ln_TextLen    = (line->ln_Text&&line->ln_Text[0])?strlen(line->ln_Text):0;
  504.  
  505.                                             if (line->ln_TextLen > fdesc[j].length)
  506.                                             {
  507.                                                 line->ln_Text[fdesc[j].length] = 0;
  508.                                                 line->ln_TextLen=fdesc[j].length;
  509.                                             }
  510.  
  511.                                             swidth                = TextLength (&trp, line->ln_Text, line->ln_TextLen);
  512.                                             xoffset                += nextxoffset;
  513.                                             nextxoffset            = (fdesc[j].length*font->tf_XSize);
  514.                                             style                = FS_NORMAL;
  515.  
  516.                                             line->ln_FgPen   = fgpen;
  517.                                             line->ln_BgPen   = bgpen;
  518.                                             line->ln_Style   = style;
  519.                                             line->ln_Data    = NULL;
  520.                                             line->ln_XOffset = xoffset;
  521.                                             line->ln_YOffset = yoffset + font->tf_Baseline;
  522.                                             line->ln_Width   = swidth;
  523.                                             line->ln_Height  = font->tf_YSize;
  524.  
  525.                                             AddTail(linelist, (struct Node *) line);
  526.  
  527.                                             j++;
  528.  
  529.                                         }
  530.  
  531.                                         if (line)
  532.                                         {
  533.                                             line->ln_Flags = LNF_LF;
  534.  
  535.                                             yoffset += font->tf_YSize;
  536.                                             maxwidth = MAX(maxwidth,xoffset + nextxoffset + font->tf_XSize);
  537.                                             total++;
  538.                                         }
  539.  
  540.                                     }
  541.  
  542.                                     icnt=0;
  543.                                 }
  544.  
  545.                                 linepos = 0;
  546.  
  547.  
  548.                             }
  549.                             else
  550.                             {
  551.                                 linebuffer[linepos]    = buffer[bufferpos];
  552.  
  553.                                 linepos++;
  554.                             }
  555.  
  556.                             bufferpos++;
  557.  
  558.                             bsig = CheckSignal(SIGBREAKF_CTRL_C);
  559.                         }
  560.  
  561. end:
  562.  
  563.                         FreePooled(dd->ddt_Pool,linebuffer,BUFFER_SIZE);
  564.                         linebuffer    = NULL;
  565.                     }
  566.                 }
  567.             }
  568.             else
  569.             {
  570.                 /* No layout to perform */
  571.                 total    = si->si_TotVert;
  572.                 maxwidth = si->si_TotHoriz;
  573.             }
  574.         }
  575.  
  576.         /* Compute the lines and columns type information */
  577.  
  578.         si->si_VertUnit  = font->tf_YSize;
  579.         si->si_VisVert   = visible = domain->Height / si->si_VertUnit;
  580.         si->si_TotVert   = total;
  581.         si->si_HorizUnit = hunit = 1;
  582.         si->si_VisHoriz  = (LONG) domain->Width / hunit;
  583.         si->si_TotHoriz  = maxwidth;
  584.  
  585.         /* Release the global data lock */
  586.  
  587.         ReleaseSemaphore(&si->si_Lock);
  588.  
  589.         /* Were we aborted? */
  590.         if (bsig == 0)
  591.         {
  592.             /* Not aborted, so tell the world of our newest attributes */
  593.  
  594.             dfadt_notify(obj, gpl->gpl_GInfo, NULL,
  595.                 GA_ID,                G(obj)->GadgetID,
  596.  
  597.                 DTA_VisibleVert,    visible,
  598.                 DTA_TotalVert,        total,
  599.                 DTA_NominalVert,    font->tf_YSize * 25,
  600.                 DTA_VertUnit,        font->tf_YSize,
  601.  
  602.                 DTA_VisibleHoriz,    (ULONG) (domain->Width / hunit),
  603.                 DTA_TotalHoriz,        maxwidth,
  604.                 DTA_NominalHoriz,    font->tf_XSize * 80,
  605.                 DTA_HorizUnit,        hunit,
  606.  
  607.                 DTA_Title,            title,
  608.                 DTA_Busy,            FALSE,
  609.                 DTA_Sync,            TRUE,
  610.             TAG_DONE);
  611.         }
  612.     }
  613.  
  614.  
  615.     return(total);
  616. }
  617.  
  618.  
  619. Object * __saveds __asm ClassDispatch
  620. (
  621.     register __a0 struct IClass    * class,
  622.     register __a2 Object        * object,
  623.     register __a1 Msg            msg
  624. )
  625. {
  626.     Object            * Result;
  627.  
  628.     struct    DDTData    * dd;
  629.  
  630.     switch(msg -> MethodID)
  631.     {
  632.         case OM_NEW:
  633.  
  634.             if(Result = (Object *)DoSuperMethodA(class,object,msg))
  635.             {
  636.                 STRPTR    buffer        = NULL;
  637.                 ULONG    bufferlen    = 0;
  638.  
  639.  
  640.                 if(GetDTAttrs(Result,
  641.                         TDTA_Buffer, &buffer,
  642.                         TDTA_BufferLen ,&bufferlen,
  643.                         TAG_DONE) != 2 || !buffer || !bufferlen)
  644.                 {
  645.  
  646.                         CoerceMethod(class,Result,OM_DISPOSE);
  647.  
  648.                         Result = NULL;
  649.                 }
  650.             }
  651.  
  652.             break;
  653.  
  654.         case OM_DISPOSE:
  655.             {
  656.                 struct List *linelist;
  657.  
  658.                 dd = INST_DATA(class,object);
  659.  
  660.                 if(GetDTAttrs(object,TDTA_LineList,&linelist,TAG_DONE) && linelist)
  661.                     NewList(linelist);
  662.  
  663.                 NewList(&(dd->ddt_List));
  664.  
  665.                 if(dd->ddt_Pool)
  666.                 {
  667.                     DeletePool(dd->ddt_Pool);
  668.                     dd->ddt_Pool    = NULL;
  669.                 }
  670.  
  671.                 Result = (Object *) DoSuperMethodA(class,object,msg);
  672.             }
  673.  
  674.             break;
  675.  
  676.         case OM_UPDATE:
  677.         case OM_SET:
  678.  
  679.  
  680.             if((Result = (Object *)DoSuperMethodA (class, object, msg)) && (OCLASS (object) == class))
  681.             {
  682.  
  683.                 struct RastPort *rp;
  684.  
  685.                 /* Get a pointer to the rastport */
  686.  
  687.                 if(rp = ObtainGIRPort (((struct opSet *) msg)->ops_GInfo))
  688.                 {
  689.                     struct gpRender gpr;
  690.  
  691.                     /* Force a redraw */
  692.  
  693.                     gpr.MethodID   = GM_RENDER;
  694.                     gpr.gpr_GInfo  = ((struct opSet *) msg)->ops_GInfo;
  695.                     gpr.gpr_RPort  = rp;
  696.                     gpr.gpr_Redraw = GREDRAW_UPDATE;
  697.                     DoMethodA (object, (Msg) &gpr);
  698.  
  699.                     /* Release the temporary rastport */
  700.                     ReleaseGIRPort (rp);
  701.                 }
  702.  
  703.                 Result = 0;
  704.  
  705.             }
  706.  
  707.             break;
  708.  
  709.         case GM_LAYOUT:
  710.  
  711.  
  712.             /* Tell everyone that we are busy doing things */
  713.  
  714.             dfadt_notify(object, ((struct gpLayout *) msg)->gpl_GInfo, NULL,
  715.                 GA_ID,       G(object)->GadgetID,
  716.                 DTA_Busy,    TRUE,
  717.                 TAG_DONE);
  718.  
  719.             /* Let the super-class partake */
  720.  
  721.             Result = (Object *) DoSuperMethodA (class, object, msg);
  722.  
  723.             /* We need to do this one asynchronously */
  724.  
  725.             Result += DoAsyncLayout (object, (struct gpLayout *) msg);
  726.  
  727.             break;
  728.  
  729.         case DTM_PROCLAYOUT:
  730.  
  731.  
  732.             /* Tell everyone that we are busy doing things */
  733.  
  734.             dfadt_notify(object, ((struct gpLayout *) msg)->gpl_GInfo, NULL,
  735.                 GA_ID,       G(object)->GadgetID,
  736.                 DTA_Busy,    TRUE,
  737.                 TAG_DONE);
  738.  
  739.             /* Let the super-class partake and then fall through to our layout method */
  740.  
  741.             DoSuperMethodA (class, object, msg);
  742.  
  743.         case DTM_ASYNCLAYOUT:
  744.  
  745.  
  746.             /* Layout the text */
  747.  
  748.             Result = (Object *) dfadt_layout(class, object, (struct gpLayout *) msg);
  749.             break;
  750.  
  751.         default:
  752.             Result = (Object *)DoSuperMethodA(class,object,msg);
  753.  
  754.             break;
  755.     }
  756.  
  757.  
  758.     return(Result);
  759. }
  760.